package com.zzh.lib.core.model;


import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * Created by ZZH on 2023/2/1.
 *
 * @date: 2023/2/1 22:26
 * @email: zzh_hz@126.com
 * @author: zzh
 * @description: com.zzh.lib.core.model
 */
public class HDirectoryModel<T> {
    private String id;
    private String name;
    private String path;
    private List<T> files = new ArrayList<>();

    public String getId() {
        return id == null ? "" : id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name == null ? "" : name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPath() {
        return path == null ? "" : path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public List<T> getFiles() {
        if (files == null) {
            return new ArrayList<>();
        }
        return files;
    }

    public void setFiles(List<T> files) {
        this.files = files;
    }

    public void addFile(T file) {
        files.add(file);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        HDirectoryModel<?> that = (HDirectoryModel<?>) o;
        return Objects.equals(path, that.path);
    }

    @Override
    public int hashCode() {
        return Objects.hash(path);
    }
}
